package cn.edu.ujn.laxlab2.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.ujn.laxlab2.dao.OrdersMapper;
import cn.edu.ujn.laxlab2.dao.User;
import cn.edu.ujn.laxlab2.dao.UserMapper;
@Service
public class UserServiceImpl implements IUserService{
	@Autowired
	private OrdersMapper ordersDao;
	@Autowired
	private UserMapper userDao;
	@Override
	public User insert(User user) {
		// TODO 自动生成的方法存根
		
		int insert = userDao.insert(user);
		return user;
	}

	@Override
	public int deleteById(int id) {
		ordersDao.deleteByOrderId(id);
		ordersDao.deleteByPrimaryKey(id);
		int deleteByPrimaryKey = userDao.deleteByPrimaryKey(id);
		return deleteByPrimaryKey;
	}

	@Override
	public int updateById(User user) {
		// TODO 自动生成的方法存根
		int updateByPrimaryKey = userDao.updateByPrimaryKey(user);
		return updateByPrimaryKey;
	}

	@Override
	public User findById(int id) {
		// TODO 自动生成的方法存根
		User user = userDao.getById(id);
		return user;
	}

	@Override
	public List<User> findAllUsers() {
		// TODO 自动生成的方法存根
		List<User> findAllUsers = userDao.findAllUsers();
		return findAllUsers;
	}

	@Override
	public List<User> selectByPrimaryKey(Integer id) {
		List<User> list = userDao.selectByPrimaryKey(id);
		return list;
	}

	@Override
	public List<User> findOrderAndProductById(int id) {
		// TODO 自动生成的方法存根
		List<User> list = userDao.findOrderAndProductById(id);
		return list;
	}

	

}
